package com.gdupt.interceptor;






import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Objects;

@Slf4j
public class loginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println(request.getRequestURI());
        log.info(request.getRequestURI());

        Object obj = request.getSession().getAttribute("userInfo");
        if(Objects.nonNull(obj)){
            return true;
        }
        response.sendRedirect("/login.jsp");
        return false;
    }

}
